// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using SnapObjects.Commons;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Specifies that a property of the model class will use the specified raw SQL SELECT statement to load data.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class SqlEmbeddedAttribute : Attribute, ISqlEmbedded
    {
        /// <summary>
        ///     Initializes a new instance of the SqlEmbeddedAttribute class.
        /// </summary>
        /// <param name="rawSql">The raw SQL SELECT statement that will be used by the current property to load data.</param>
        public SqlEmbeddedAttribute(string rawSql)
        {
            this.RawSql = rawSql;

            Check.NotEmpty(rawSql, nameof(rawSql));
        }

        /*public SqlEmbeddedAttribute(string rawSql, Type modelType)
        {
            this.RawSql = rawSql;
            this.ResultType = modelType;

            Check.NotEmpty(rawSql, nameof(rawSql));
            Check.NotNull(modelType, nameof(modelType));
        }*/

        /// <summary>
        ///     Gets the raw SQL SELECT statement that will be used to load data for the current property.
        /// </summary>
        public string RawSql { get; }

        //public Type ResultType { get; }

        /// <summary>
        ///     Gets or sets the value of the parameter that is required when loading data for the current property.
        /// </summary>
        public string ParamValue { get; set; }
    }
}
